#pragma once

#include <QMainWindow>
#include <QInputDialog>
#include <QFileDialog>
#include <QMessageBox>

#include <QSettings>
#include <QFileIconProvider>

// Qt Network
#include <QTcpSocket>
#include <QHostAddress>
#include <QHostInfo>

// Qt Xml
#include <QDomDocument>
#include <QXmlStreamWriter>

#include "header.h"
#include "Util/sendfilewidget.h"
#include "Util/socketqueue.h"

namespace Ui {
    class Client;
}

class Client : public QMainWindow
{
    Q_OBJECT
protected:
    void closeEvent(QCloseEvent *) override;

public:
    explicit Client(QWidget *parent = nullptr);

    void writeDirRequest(const QString &path, const QString &sp = "");
    void parseReceiveMsg(const QByteArray &array);

private slots:
    void onTcpReadyRead();
    void onUpload();

    void on_btnConnect_clicked();

private:
    Ui::Client *ui;
    QTcpSocket *mSocket;
    QString serverDir;

    void addSocketQueue(SocketQueue *sq);
    void writeFirstSocketQueue();
    QList<SocketQueue*> mSocketQueueList;
    QByteArray mSocketBuffer;

    QMap<QString, SendFileWidget*> mMapPathToWidget;

};

